{include file="header.html"}
<body class="gr">

<div class="navBar">
	<a class="left" href="javascript:history.back()"><i class="return"></i></a>
	<div class="titleView">忘记密码</div>
</div>

<div class="forget-index main-top">
	<form action="?tpl=forget.password" method="post">
	<div class="tip">请输入您在商富商城注册时的手机号码</div>
	<div class="inputView">
		<div><i></i><input type="text" name="mobile" id="mobile" /></div>
	</div>
	<div class="code">
		<a href="javascript:void(0)"><span>发送短信</span></a>
		<div class="inputView"><div><i></i><input type="text" name="code" id="code" /></div></div>
	</div>
	<div class="buttonView">
		<a href="javascript:void(0)" class="btn">下一步</a>
	</div>
	</form>
</div>

{include file="footer.html"}
<script>
var _mobileText = '', _codeText = '', _getCode = false, _count = 0, _timer = null;
$(function(){
	$('#mobile').placeholder('手机号码');
	$('#code').placeholder('验证码');
	$('.code a').click(function(){
		if(_getCode)return false;
		if(!$('#mobile').val().length){
			$.overloadError('请输入手机号码');
			return false;
		}
		var _this = $(this).html('<div class="preloader"></div>');
		_getCode = true;
		_mobileText = _codeText = '';
		$.postJSON('api.php?app=passport&act=forget_send_sms', { mobile:$('#mobile').val() }, function(json){
			if(json.error!=0){
				$.overloadError(json.msg);
				return;
			}
			console.log(json.data.code);
			_mobileText = json.data.mobile;
			_codeText = json.data.code;
			_count = 60;
			_timer = setInterval(function(){
				_count--;
				if (_count<=0) {
					clearInterval(_timer);_getCode = false;
					_this.removeClass('disabled').html('<span>再次发送</span>');
				} else {
					_this.addClass('disabled').html('<span>'+_count+'s后重发</span>');
				}
			}, 1000);
		});
	});
	$('.btn').click(function(){
		if(!$('#mobile').val().length){
			$.overloadError('请输入手机号码');
			return false;
		}
		if(!$('#code').val().length){
			$.overloadError('请输入验证码');
			return false;
		}
		if($('#code').val()!=_codeText){
			$.overloadError('验证码不正确');
			return false;
		}
		$('form').submit();
	});
});
</script>
